package day02_homework;

import java.util.Scanner;

public class Test05 {
    public static void main(String[] args) {
        Person p = new Person();
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入姓名：");
        String name = sc.next();
        if (name.length() == 0) {
            System.out.println("姓名不能为空");
        } else {
            p.setName(name);
        }
        System.out.println("请输入年龄：");
        int age = sc.nextInt();
        if (age >= 0 && age <= 100) {
            p.setAge(age);
        } else {
            System.out.println("年龄必须在0-100之间");
        }
        System.out.println("姓名：" + p.getName() + "年龄：" + p.getAge());
    }
}

class Person {
    private String name;
    private int age;

    public Person() {
    }

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}